//
//  LegalAdviceView.m
//  DJS
//
//  Created by 浪尖渝力 on 2018/1/22.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "LegalAdviceView.h"
#import "SoundViewController.h"
@implementation LegalAdviceView
-(void)creatView{
    self.backgroundColor=_LightGrey;
    _scrollView=[UIScrollView new];
    [self addSubview:_scrollView];
    [_scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    _scrollView.scrollsToTop =NO;
    
    _scrollView.showsVerticalScrollIndicator = FALSE;
    _scrollView.showsHorizontalScrollIndicator = FALSE;
    _scrollView.bounces = NO;
    if (@available(iOS 11.0, *)) {
        self.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.viewController.automaticallyAdjustsScrollViewInsets = NO;
    }
    
    UIView *topView=[UIView new];
    [_scrollView addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(NAV_HEIGHT);
        make.width.mas_equalTo(_mainW);
        make.height.mas_equalTo(90);
    }];
    
    [self creatTopView:topView];
    
    NSString *consult_content=[_dic objectForKey:@"consult_content"];
    CGSize size=[ZQTools getNSStringSize:consult_content andViewWight:_mainW-30 andFont:18];
    UIView *contentView=[UIView new];
    [_scrollView addSubview:contentView];
    [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(5);
        make.width.mas_equalTo(_mainW-10);
        make.top.mas_equalTo(topView.mas_bottom).mas_equalTo(20);
        make.height.mas_equalTo(size.height+60);
    }];
    contentView.layer.cornerRadius=5;
    [self creatContentView:contentView];
    
    UIView *zongHeView=[UIView new];
    [_scrollView addSubview:zongHeView];
    [zongHeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(contentView);
        make.top.mas_equalTo(contentView.mas_bottom).mas_equalTo(20);
        make.height.mas_equalTo(170);
    }];
    zongHeView.layer.cornerRadius=5;
    [self creatZongHeView:zongHeView];
    
    
    UIImageView *imaView=[UIImageView new];
    [_scrollView addSubview:imaView];
    [imaView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(50);
        make.top.mas_equalTo(contentView.mas_bottom).mas_equalTo(-20);
        make.height.mas_equalTo(55);
        make.width.mas_equalTo(30);
    }];
    imaView.image=[UIImage imageNamed:@"纽带"];
    
    UIImageView *imaView12=[UIImageView new];
    [_scrollView addSubview:imaView12];
    [imaView12 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_mainW-80);
        make.top.mas_equalTo(contentView.mas_bottom).mas_equalTo(-20);
        make.height.mas_equalTo(55);
        make.width.mas_equalTo(30);
    }];
    imaView12.image=[UIImage imageNamed:@"纽带"];
    
    NSNumber *consult_status=[_dic objectForKey:@"consult_status"];
    if (consult_status.integerValue==0) {
   
        NSNumber *consult_send_status=[_dic objectForKey:@"consult_send_status"];
        if (consult_send_status.integerValue==1) {
            _btn1=[UIButton new];
            [self addSubview:_btn1];
            [_btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(0);
                make.width.mas_equalTo(_mainW/2);
                make.height.mas_equalTo(50);
                make.bottom.mas_equalTo(0);
            }];
            [_btn1 setTitle:@"接受" forState:0];
            [_btn1 setTitleColor:[UIColor whiteColor] forState:0];
            _btn1.backgroundColor=ColorWithRGB(183, 157, 108);
            [_btn1 addTarget:self action:@selector(jieShou:) forControlEvents:UIControlEventTouchUpInside];
            
            _btn2=[UIButton new];
            [self addSubview:_btn2];
            [_btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(_btn1.mas_right);
                make.width.mas_equalTo(_mainW/2);
                make.height.mas_equalTo(50);
                make.bottom.mas_equalTo(0);
            }];
            [_btn2 setTitle:@"拒绝" forState:0];
            [_btn2 setTitleColor:[UIColor whiteColor] forState:0];
            _btn2.backgroundColor=ColorWithRGB(93, 148, 172);
            [_btn2 addTarget:self action:@selector(jieShou2:) forControlEvents:UIControlEventTouchUpInside];
        }
        if (consult_send_status.integerValue==2) {
            NSNumber *consult_audit_status=[_dic objectForKey:@"consult_audit_status"];
            if (consult_audit_status.integerValue==0||consult_audit_status.integerValue==3) {
                _LuYingImage=[UIImageView new];
                [_scrollView addSubview:_LuYingImage];
                [_LuYingImage mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerX.mas_equalTo(topView);
                    make.top.mas_equalTo(zongHeView.mas_bottom).mas_equalTo(160);
                    make.height.mas_equalTo(60);
                    make.width.mas_equalTo(37);
                }];
                _LuYingImage.image=[UIImage imageNamed:@"Mic-拷贝"];
                _LuYingImage.userInteractionEnabled=YES;
                
                UIView *luyingView=[UIView new];
                [_scrollView addSubview:luyingView];
                [luyingView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.center.mas_equalTo(_LuYingImage);
                    make.width.height.mas_equalTo(200);
                }];
                luyingView.backgroundColor=[UIColor clearColor];
                
                UITapGestureRecognizer *tapGesture2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushToLuYing:)];
                [luyingView addGestureRecognizer:tapGesture2];
                _scrollView.contentSize = CGSizeMake(0,170+size.height+90+500);
                
                UILabel *label=[UILabel new];
                [_scrollView addSubview:label];
                [label mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerX.mas_equalTo(_LuYingImage);
                    make.top.mas_equalTo(_LuYingImage.mas_bottom).mas_equalTo(10);
                }];
                label.text=@"编辑语音";
                label.font=[UIFont systemFontOfSize:18];
                label.textColor=ColorWithRGB(183, 157, 108);
               
                label.userInteractionEnabled=YES;
                UITapGestureRecognizer *tapGesture12 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushToLuYing:)];
                [label addGestureRecognizer:tapGesture12];
            }
            
            if (consult_audit_status.integerValue==1||consult_audit_status.integerValue==2){
                UIView *huiFuView=[UIView new];
                [self addSubview:huiFuView];
                [huiFuView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.right.mas_equalTo(zongHeView);
                    make.top.mas_equalTo(zongHeView.mas_bottom).mas_equalTo(20);
                    make.height.mas_equalTo(160);
                }];
                huiFuView.backgroundColor=[UIColor whiteColor];
                huiFuView.layer.cornerRadius=5;
                [self creatHuiFu:huiFuView];
                _scrollView.contentSize = CGSizeMake(0,170+size.height+90+400);
            }
        }
        
      
        return;
    }
    if (consult_status.integerValue==1) {
        UIView *huiFuView=[UIView new];
        [self addSubview:huiFuView];
        [huiFuView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(zongHeView);
            make.top.mas_equalTo(zongHeView.mas_bottom).mas_equalTo(20);
            make.height.mas_equalTo(160);
        }];
        huiFuView.backgroundColor=[UIColor whiteColor];
        huiFuView.layer.cornerRadius=5;
        [self creatHuiFu:huiFuView];
         _scrollView.contentSize = CGSizeMake(0,170+size.height+90+400);
        
    }
    
    
    if (consult_status.integerValue==2) {
        UIView *huiFuView=[UIView new];
        [self addSubview:huiFuView];
        [huiFuView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(zongHeView);
            make.top.mas_equalTo(zongHeView.mas_bottom).mas_equalTo(20);
            make.height.mas_equalTo(160);
        }];
        huiFuView.backgroundColor=[UIColor whiteColor];
        huiFuView.layer.cornerRadius=5;
        [self creatHuiFu:huiFuView];
        
        NSString *evaluate_content=[_dic objectForKey:@"evaluate_content"];
        CGSize size3=[ZQTools getNSStringSize:evaluate_content andViewWight:_mainW-40 andFont:17];
        UIView *pingJiaView=[UIView new];
        [_scrollView addSubview:pingJiaView];
        [pingJiaView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(huiFuView);
            make.height.mas_equalTo(80+size3.height);
            make.top.mas_equalTo(huiFuView.mas_bottom).mas_equalTo(20);
        }];
        pingJiaView.backgroundColor=[UIColor whiteColor];
        pingJiaView.layer.cornerRadius=5;
        [self creatPingJiaView:pingJiaView];
    }
    
}
-(void)creatTopView:(UIView *)topView{
    topView.backgroundColor=[UIColor whiteColor];
    
    UIView *beiJin=[UIView new];
    [topView addSubview:beiJin];
    [beiJin mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(14);
        make.centerY.mas_equalTo(0);
        make.width.height.mas_equalTo(52);
    }];
    beiJin.layer.cornerRadius=26;
    beiJin.backgroundColor=_tianLanColor;
    beiJin.alpha=0.3;
    
    UIImageView *userImage=[UIImageView new];
    [topView addSubview:userImage];
    [userImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.centerY.mas_equalTo(0);
        make.width.height.mas_equalTo(50);
    }];
    userImage.layer.masksToBounds=YES;
    userImage.layer.cornerRadius=25;
    
    NSString *news_cover=[_dic objectForKey:@"user_icon"];
    news_cover=[NSString stringWithFormat:@"%@%@",_addressUrl,news_cover];
    [userImage sd_setImageWithURL:[NSURL URLWithString:news_cover]];
    
    UILabel *label=[UILabel new];
    [topView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(userImage.mas_right).mas_equalTo(10);
        make.right.mas_equalTo(-140);
    }];
    label.text=[_dic objectForKey:@"user_nickname"];
    label.textColor=ColorWithRGB(49, 49, 49);
    label.font=[UIFont systemFontOfSize:20];
    
    UIImageView *image=[UIImageView new];
    [topView addSubview:image];
    [image mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.width.mas_equalTo(100);
    }];
    
    NSNumber *consult_status=[_dic objectForKey:@"consult_status"];
    if (consult_status.integerValue==0) {
        image.image=[UIImage imageNamed:@"待接受"];
        
        NSNumber *consult_send_status=[_dic objectForKey:@"consult_send_status"];
        if (consult_send_status.integerValue==1) {
            image.image=[UIImage imageNamed:@"待接受"];
        }if (consult_send_status.integerValue==2) {
            image.image=[UIImage imageNamed:@"进行中"];
        }
        
    }
    if (consult_status.integerValue==2) {
         image.image=[UIImage imageNamed:@"已完成"];
    }
    
}
-(void)creatContentView:(UIView *)topView{
    topView.backgroundColor=[UIColor whiteColor];
    UIImageView *imageView=[UIImageView new];
    [topView addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(10);
        make.width.height.mas_equalTo(20);
    }];
    imageView.image=[UIImage imageNamed:@"疑问-(1)"];
    
    UILabel *contentLabel=[UILabel new];
    [topView addSubview:contentLabel];
    [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(imageView.mas_right).mas_equalTo(7);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(imageView);
    }];
    contentLabel.numberOfLines=0;
    contentLabel.text=[_dic objectForKey:@"consult_content"];
    contentLabel.font=[UIFont systemFontOfSize:18];
    contentLabel.textColor=ColorWithRGB(49, 49, 49);
    
}-(void)creatZongHeView:(UIView *)topView{
    topView.backgroundColor=[UIColor whiteColor];
    UIView *view1=[UIView new];
    [topView addSubview:view1];
    [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(18);
        make.height.mas_equalTo(50);
        make.right.mas_equalTo(0);
    }];
    
    UILabel *label1=[UILabel new];
    [view1 addSubview:label1];
    [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    label1.text=@"案件类型";
    label1.font=[UIFont systemFontOfSize:18];
    label1.textColor=ColorWithRGB(49, 49, 49);
    
    UILabel *label2=[UILabel new];
    [view1 addSubview:label2];
    [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
    }];
    label2.text=[_dic objectForKey:@"consult_ct_name"];
    label2.textColor=ColorWithRGB(79, 79, 79);
    label2.font=[UIFont systemFontOfSize:16];
    
    UIView *xianView=[UIView new];
    [topView addSubview:xianView];
    [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(view1.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView.backgroundColor=_LightGrey;
    
    UIView *view2=[UIView new];
    [topView addSubview:view2];
    [view2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(xianView.mas_bottom);
        make.height.mas_equalTo(50);
        make.right.mas_equalTo(0);
    }];
    
    UILabel *label3=[UILabel new];
    [view2 addSubview:label3];
    [label3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    label3.text=@"咨询价格";
    label3.font=[UIFont systemFontOfSize:18];
    label3.textColor=ColorWithRGB(49, 49, 49);
    
    UILabel *label4=[UILabel new];
    [view2 addSubview:label4];
    [label4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
    }];
    label4.text=[NSString stringWithFormat:@"¥%@",[_dic objectForKey:@"consult_money"]];
    label4.textColor=ColorWithRGB(79, 79, 79);
    label4.font=[UIFont systemFontOfSize:16];
    
    
    UIView *xianView2=[UIView new];
    [topView addSubview:xianView2];
    [xianView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(view2.mas_bottom);
        make.height.mas_equalTo(1);
    }];
    xianView2.backgroundColor=_LightGrey;
    
    UIView *view3=[UIView new];
    [topView addSubview:view3];
    [view3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(xianView2.mas_bottom);
        make.height.mas_equalTo(50);
        make.right.mas_equalTo(0);
    }];
    
    UILabel *label5=[UILabel new];
    [view3 addSubview:label5];
    [label5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(0);
    }];
    label5.text=@"发布时间";
    label5.font=[UIFont systemFontOfSize:18];
    label5.textColor=ColorWithRGB(49, 49, 49);
    
    NSNumber *time=[_dic objectForKey:@"consult_time"];
    UILabel *label6=[UILabel new];
    [view3 addSubview:label6];
    [label6 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(0);
    }];
    label6.text=[ZQTools changeTimeCuo:@"YYYY-MM-dd HH:mm:ss" :[NSString stringWithFormat:@"%@",time]];
    label6.textColor=ColorWithRGB(79, 79, 79);
    label6.font=[UIFont systemFontOfSize:16];
    
}
-(void)creatHuiFu:(UIView *)huiView{
    UIImageView *imagView=[UIImageView new];
    [huiView addSubview:imagView];
    [imagView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(10);
        make.width.mas_equalTo(10);
        make.height.mas_equalTo(20);
    }];
    imagView.image=[UIImage imageNamed:@"Mic-"];
    
    UILabel *label=[UILabel new];
    [huiView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(imagView.mas_right).mas_equalTo(10);
        make.centerY.mas_equalTo(imagView);
    }];
    label.text=@"我的回复";
    label.font=[UIFont systemFontOfSize:17];
    label.textColor=ColorWithRGB(49, 49, 49);
    
    NSNumber *consult_audit_status=[_dic objectForKey:@"consult_audit_status"];
    
    UILabel *zhuangTaiLabel=[UILabel new];
    [huiView addSubview:zhuangTaiLabel];
    [zhuangTaiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(label);
    }];
    if (consult_audit_status.integerValue==1) {
        zhuangTaiLabel.text=@"未审核";
    }
    if (consult_audit_status.integerValue==2) {
        zhuangTaiLabel.text=@"已通过";
    }
    zhuangTaiLabel.textColor=ColorWithRGB(240, 149, 143);
    zhuangTaiLabel.font=[UIFont systemFontOfSize:17];
    
    NSData *Data=[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.djiaoshou.com/yuyin.gif"]];
    UIImage *image=[UIImage imageWithData:Data];
    
    _shiTing=[UIImageView new];
    [huiView addSubview:_shiTing];
    [_shiTing mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.height.mas_equalTo(40);
        make.width.mas_equalTo(40/image.size.height*image.size.width);
        make.centerY.mas_equalTo(0);
    }];
    _shiTing.image=[UIImage imageNamed:@"录音"];
    _shiTing.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGesture4 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(creatBoFang)];
    [_shiTing addGestureRecognizer:tapGesture4];
    
    UILabel *timeLabel2=[UILabel new];
    [self addSubview:timeLabel2];
    [timeLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_shiTing);
        make.left.mas_equalTo(_shiTing.mas_right).mas_equalTo(20);
    }];
    timeLabel2.textColor=ColorWithRGB(149, 149, 149);
    timeLabel2.font=[UIFont systemFontOfSize:17];
    NSNumber *sl_time_long=[_dic objectForKey:@"sl_time_long"];
    timeLabel2.text=[NSString stringWithFormat:@"%@'",sl_time_long];
    
}
-(void)creatPingJiaView:(UIView *)topView{
    NSString *evaluate_content=[_dic objectForKey:@"evaluate_content"];
     NSString *consult_content=[_dic objectForKey:@"consult_content"];
    CGSize size3=[ZQTools getNSStringSize:evaluate_content andViewWight:_mainW-40 andFont:17];
    CGSize size2=[ZQTools getNSStringSize:consult_content andViewWight:_mainW-40 andFont:17];
    UIView *xianView2=[UIView new];
    [topView addSubview:xianView2];
    [xianView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(10);
        make.width.mas_equalTo(3);
        make.height.mas_equalTo(20);
    }];
    xianView2.backgroundColor=_backgroundColor;
    
    UILabel *woDeLabel2=[UILabel new];
    [topView addSubview:woDeLabel2];
    [woDeLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(xianView2);
        make.left.mas_equalTo(xianView2.mas_right).mas_equalTo(10);
    }];
    woDeLabel2.text=@"我的评价";
    woDeLabel2.textColor=ColorWithRGB(49, 49, 49);
    woDeLabel2.font=[UIFont systemFontOfSize:22];
    
    NSNumber *evaluate_score=[_dic objectForKey:@"evaluate_score"];
    int typeNum2=evaluate_score.doubleValue*10;
    int typeNum=typeNum2%10;
    int index=5-evaluate_score.floatValue;
    
    
    for (int i=0; i<5; i++) {
        UIImageView *xingImage=[UIImageView new];
        [topView addSubview:xingImage];
        [xingImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-10-25*i);
            make.height.width.mas_equalTo(20);
            make.centerY.mas_equalTo(woDeLabel2);
        }];
        
        if (typeNum>0) {
            if (i<index) {
                xingImage.image=[UIImage imageNamed:@"评分1"];
            }
            if (i==index) {
                xingImage.image=[UIImage imageNamed:@"评分3"];
            }
            if (i>index) {
                xingImage.image=[UIImage imageNamed:@"评分2"];
            }
        }
        else{
            if (i<index) {
                xingImage.image=[UIImage imageNamed:@"评分1"];
            }
            else{
                xingImage.image=[UIImage imageNamed:@"评分2"];
            }
        }
    }
    
    UILabel *pingFen=[UILabel new];
    [topView addSubview:pingFen];
    [pingFen mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(woDeLabel2);
        make.right.mas_equalTo(-140);
    }];
    pingFen.text=@"评分:";
    pingFen.textColor=ColorWithRGB(149, 149, 149);
    pingFen.font=[UIFont systemFontOfSize:16];
    
    UILabel *lable12=[UILabel new];
    [topView addSubview:lable12];
    [lable12 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(xianView2);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(woDeLabel2.mas_bottom).mas_equalTo(20);
    }];
    lable12.textColor=ColorWithRGB(79, 79, 79);
    lable12.text=evaluate_content;
    lable12.font=[UIFont systemFontOfSize:17];
    
    _scrollView.contentSize = CGSizeMake(0,740+size3.height+size2.height);
}
-(IBAction)jieShou:(id)sender{
    
    NSNumber *assign_id=[_dic objectForKey:@"assign_id"];
    NSNumber *consult_id=[_dic objectForKey:@"consult_id"];
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];
    NSString *token=[userDic objectForKey:@"token"];
    NSNumber *waiter_id1=[userDic objectForKey:@"waiter_id"];
    NSString *waiter_id=[NSString stringWithFormat:@"%@",waiter_id1];
    
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%@",assign_id],@"assign_id",@"1",@"action",[NSString stringWithFormat:@"%@",consult_id],@"consult_id",token,@"token",waiter_id,@"waiter_id",@"1",@"user_role", nil];
    [ZQTools AFNPostDataUrl:@"waiter/consult/accept_consult" Dict:dic andTableView:nil andViewController:self.viewController andSuccessBlock:^(id responseObject) {
        [_btn1 removeFromSuperview];
        [_btn2 removeFromSuperview];
        _customSelectedBlock();
        
    } anderrorBlock:nil];
    
}
-(IBAction)jieShou2:(id)sender{
    
    NSNumber *assign_id=[_dic objectForKey:@"assign_id"];
    NSNumber *consult_id=[_dic objectForKey:@"consult_id"];
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];
    NSString *token=[userDic objectForKey:@"token"];
    NSNumber *waiter_id1=[userDic objectForKey:@"waiter_id"];
    NSString *waiter_id=[NSString stringWithFormat:@"%@",waiter_id1];
    
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%@",assign_id],@"assign_id",@"2",@"action",[NSString stringWithFormat:@"%@",consult_id],@"consult_id",token,@"token",waiter_id,@"waiter_id",@"1",@"user_role", nil];
    [ZQTools AFNPostDataUrl:@"waiter/consult/accept_consult" Dict:dic andTableView:nil andViewController:self.viewController andSuccessBlock:^(id responseObject) {
        [_btn1 removeFromSuperview];
        [_btn2 removeFromSuperview];
        _customSelectedBlock();
        
    } anderrorBlock:nil];
    
}
-(void)pushToLuYing:(UITapGestureRecognizer *)tap{
    SoundViewController *soud=[[SoundViewController alloc] init];
    soud.consult_id=[_dic objectForKey:@"consult_id"];
    [ZQTools pushNextViewController:self.viewController andRootController:soud];
}

-(void)creatBoFang{
    
    NSData *Data=[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.djiaoshou.com/yuyin.gif"]];
    UIImage *image=[UIImage imageWithData:Data];
    
    _GifImageView=[UIImageView new];
    [self addSubview:_GifImageView];
    [_GifImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_shiTing);
        make.left.mas_equalTo(_shiTing);
        make.height.mas_equalTo(40);
        make.width.mas_equalTo(40/image.size.height*image.size.width);
    }];
    
    _shiTing.hidden=YES;
    _shiTing.userInteractionEnabled=NO;
    
    
    NSString  *name = @"yuyin.gif";
    NSString  *filePath = [[NSBundle bundleWithPath:[[NSBundle mainBundle] bundlePath]] pathForResource:name ofType:nil];
    NSData  *imageData = [NSData dataWithContentsOfFile:filePath];
    
    _GifImageView.image = [UIImage sd_animatedGIFWithData:imageData];

    
    NSString *videoFilePath=[NSString stringWithFormat:@"%@%@",_addressUrl,[_dic objectForKey:@"sl_file"]];
    NSURL * url = [NSURL URLWithString:videoFilePath];
    self.player = [[SUPlayer new] initWithURL:url];
    [self.player addObserver:self forKeyPath:@"progress" options:NSKeyValueObservingOptionNew context:nil];
    [self.player addObserver:self forKeyPath:@"duration" options:NSKeyValueObservingOptionNew context:nil];
    [self.player addObserver:self forKeyPath:@"cacheProgress" options:NSKeyValueObservingOptionNew context:nil];
    [self.player play];
}


- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context {
    if ([keyPath isEqualToString:@"progress"]) {
        [self convertStringWithTime2];
        
    }
    if ([keyPath isEqualToString:@"duration"]) {
        if (self.player.duration > 0) {
            //            self.timeLabel.text = [self convertStringWithTime:self.player.duration];
            //            self.timeLabel.hidden = NO;
        }else {
            //            self.timeLabel.hidden = YES;
            
        }
    }
    if ([keyPath isEqualToString:@"cacheProgress"]) {
        
    }
}
- (NSString *)convertStringWithTime2 {
    
    
    int timelength=self.player.duration-self.player.duration * self.player.progress;
    if (isnan(timelength)) timelength = 0.f;
    int min = timelength / 60.0;
    int sec = timelength - min * 60;
    NSString * minStr = min > 9 ? [NSString stringWithFormat:@"%d",min] : [NSString stringWithFormat:@"0%d",min];
    NSString * secStr = sec > 9 ? [NSString stringWithFormat:@"%d",sec] : [NSString stringWithFormat:@"0%d",sec];
    NSString * timeStr = [NSString stringWithFormat:@"%@:%@",minStr, secStr];
    if ([timeStr isEqualToString:@"00:01"]) {
        
        [_GifImageView removeFromSuperview];
        _shiTing.hidden=NO;
        _shiTing.userInteractionEnabled=YES;;
    }
    
    return timeStr;
}
@end
